<?php
include_once('simple_html_dom.php');

function ladeMensaplan($url) {
	
	//Tage
	
	$deutscheTage = array('Montag','Dienstag','Mittwoch','Donnerstag', 'Freitag');
	
	
    // create HTML DOM
    $html = file_get_html($url);


    // get overview
    foreach($html->find('table') as $tabelle) {


        $key = '';
        $val = '';
        
        $pruefWert = $tabelle->find('h2',0)->plaintext;

foreach($deutscheTage as $Index=>$tag)
{
	$pos = strpos($pruefWert,$tag);

if($pos === false) {
 // string needle NOT found in haystack
}
else {


$menu1 = $tabelle->find('td',1);
$menu1_essen = "";

//Alle Menütexte killen
foreach($menu1->find('*') as $eintrag)
{
	if ($eintrag->tag == "h2")
	$eintrag->innertext = '';
}

$menu2= $tabelle->find('td',2);
$menu2_essen = "";

//Alle Menütexte killen
foreach($menu2->find('*') as $eintrag)
{
	if ($eintrag->tag == "h2")
	$eintrag->innertext = '';
}

$menu3 = $tabelle->find('td',3);
$menu3_essen = "";

//Alle Menütexte killen
foreach($menu3->find('*') as $eintrag)
{
	if ($eintrag->tag == "h2")
	$eintrag->innertext = '';
}

echo "<li class=\"group\">".$pruefWert."</li>";
echo "<li>".$menu1->plaintext."</li>";
echo "<li>".$menu2->plaintext."</li>";
echo "<li>".$menu3->plaintext."</li>";


}

}



        $ret[$key] = $val;
    }
    
    // clean up memory
    $html->clear();
    unset($html);

    return $ret;
}


// -----------------------------------------------------------------------------
// test it!
$ret = ladeMensaplan('http://www.studentenwerk-muenster.de/text/essen_trinken/sp_m1.php');

?>